#include "prime.h"

int IsPrime(int N)
{
	int i, j;
	if (N == 2)
		return YES;
	else
		if (N < 2 || N % 2 == 0)
			return NO;
		else
		{
			j = (int)sqrt(  double(N + 1) );
			for (i = 3; i <= j; i = i + 2)
				if (N % i == 0)
					return NO;
		}
	return YES;
}

int nextPrime(int start)
{
	while (1)
	{
		if (IsPrime(start++))
			break;
	}
	return start - 1;
}